package com.chidopi.market.util;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class ClassUtils {
	
	public static Object getUserDetails(){
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		if(auth != null) return auth.getPrincipal();
		return null;
	}
	
	@SuppressWarnings("rawtypes")
	public static boolean hasInterface(Object object, Class intf){
		boolean result = false;
		Class[] intfs =  object.getClass().getInterfaces();		
		for(int i = 0; i < intfs.length; i++){
			if(intfs[i] == intf){
				result = true;
				break;
			}
		}
		               
		return result;
	}
}
